import requests

# 登录成功,获得令牌
resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/login",
                     json={"mobile": "13800000002", "password": "123456"})
token = resp.json().get("data")


# 添加员工
# resp=requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
#               headers={"Content-Type":"application/json","Authorization":token},
#               json={"username":"张好好","mobile":"13146789034","workNumber":"012"})
# print("添加员工：", resp.json())

# 查询员工
resp = requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/1063705989926227968",
                    headers={"Authorization": token})
print("查询员工：", resp.json())

# 修改员工
resp = requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/1063705989926227968",
                    headers={"Authorization": token},
                    json={"username": "至宗宝99"})
print("修改员工：", resp.json())

# 删除员工
resp = requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/1063705989926227968",
                       headers={"Authorization": token})
print("删除员工：", resp.json())
